
package com.blog.basic.config;

import com.blog.basic.interceptor.LoginIntercepetor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LoginConfig implements WebMvcConfigurer {

    @Autowired
    private LoginIntercepetor loginIntercepetor;
    
    /**
    * @Description: 注册拦截器
    * @Param: 
    * @return: 
    * @Author: Mr.Zhao
    * @Date: 2022/4/5
    */ 
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(loginIntercepetor);
        interceptorRegistration
                .addPathPatterns("/**") //拦截所有
                .excludePathPatterns("/static/**") //放行静态资源
                .excludePathPatterns("/article/**") //放行首页 文章资源
                .excludePathPatterns("/admin/login","/admin/dologin"); //放行登陆


    }
}

